
#import "WWDADTextField.h"

@implementation WWDADTextField

- initFrame:(const NXRect *)r
{
    const char  *WDRAG_PBTYPE[] = { NXFilenamePboardType, NULL};


    [super initFrame:r];
    [self registerForDraggedTypes:WDRAG_PBTYPE count:1];
    [[self cell] setScrollable:YES];
	
    return self;
}

- awake
{
  const char  *WDRAG_PBTYPE[] = { NXFilenamePboardType, NULL};


  [super awake];
  [self registerForDraggedTypes:WDRAG_PBTYPE count:1];

  return self;
}



////////////////////////////////////////////////////////////////////
//			Font stuff
///////////////////////////////////////////////////////////////////

- changeFont:sender
{
  [cell setFont:[sender convertFont:[cell font]]];
  return self;
}


- changeIBFont:sender
{
  [cell setFont:[sender convertFont:[cell font]]];
  return self;
}


////////////////////////////////////////////////////////////////////
//			Dragging stuff
///////////////////////////////////////////////////////////////////


- (NXDragOperation)draggingEntered:(id <NXDraggingInfo>)sender
{
    Pasteboard    *pboard;
    const NXAtom  *theType;


    pboard = [sender draggingPasteboard];
    theType = [pboard types];

    if (*theType != NXFilenamePboardType)
    {  return NX_DragOperationCopy;
    }
    return NX_DragOperationNone;
}

- (NXDragOperation)draggingUpdated:(id <NXDraggingInfo>)sender
{
	return NX_DragOperationCopy;
}


- (BOOL)performDragOperation:(id <NXDraggingInfo>)sender
{
    Pasteboard    *pboard;
    char          *argv;
    int           len;
    const NXAtom  *theType;


    pboard = [sender draggingPasteboard];
    theType = [pboard types];

    if (*theType != NXFilenamePboardType)
    {  if ([pboard readType:NXFilenamePboardType data:&argv length:&len] == nil)
       {  return NO;
       }
       else
       {  [self setStringValue:(const char *)argv];
	  [self display];
          return YES;
       }
    }
    else
    {  return NO;
    }
}

@end
